﻿namespace AC.ExtendedRenderer.Toolkit
{
    using AC.ExtendedRenderer.Toolkit.Drawing;
    using AC.ExtendedRenderer.Toolkit.Utils;
    using ComponentFactory.Krypton.Toolkit;
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Drawing.Text;
    using System.Security.Permissions;
    using System.Windows.Forms;

    [ToolboxBitmap(typeof(ListView))]
    public class KryptonListView : ListView
    {
        private Color _alternateRowColor = Color.LightGray;
        private bool _alternateRowColorEnabled = true;
        private bool _autoSizeLastColumn = true;
        private bool _designMode;
        private bool _enableDragDrop;
        private bool _enableHeaderGlow;
        private bool _enableHeaderHotTrack;
        private bool _enableHeaderRendering;
        private bool _enableSelectionBorder;
        private bool _enableSorting = true;
        private bool _enableVistaCheckBoxes = true;
        private bool _forceLeftAlign;
        private Color _gradientEndColor = Color.Gray;
        private Color _gradientMiddleColor = Color.LightGray;
        private Color _gradientStartColor = Color.White;
        private bool _indendFirstItem = true;
        private ListViewItem _itemDnD;
        private int _lineAfter = -1;
        private int _lineBefore = -1;
        private IDisposable _mementoBack;
        private IPalette _palette;
        private PaletteBackInheritRedirect _paletteBack;
        private PaletteBorderInheritRedirect _paletteBorder;
        private PaletteContentInheritRedirect _paletteContent;
        private PaletteRedirect _paletteRedirect;
        private bool _persistentColors;
        private bool _selectEntireRowOnSubItem = true;
        private bool _useStyledColors;
        private IContainer components;
        private ImageList ilCheckBoxes;
        private ListViewColumnSorter lvwColumnSorter;

        public KryptonListView()
        {
            base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            base.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            base.UpdateStyles();
            base.OwnerDraw = true;
            this._palette = KryptonManager.CurrentGlobalPalette;
            if (this._palette != null)
            {
                this._palette.PalettePaint += new EventHandler<PaletteLayoutEventArgs>(this.OnPalettePaint);
            }
            KryptonManager.GlobalPaletteChanged += new System.EventHandler(this.OnGlobalPaletteChanged);
            this._paletteRedirect = new PaletteRedirect(this._palette);
            this._paletteBack = new PaletteBackInheritRedirect(this._paletteRedirect);
            this._paletteBorder = new PaletteBorderInheritRedirect(this._paletteRedirect);
            this._paletteContent = new PaletteContentInheritRedirect(this._paletteRedirect);
            this.InitColors();
            this.lvwColumnSorter = new ListViewColumnSorter();
            base.ListViewItemSorter = this.lvwColumnSorter;
            if (this._selectEntireRowOnSubItem)
            {
                base.FullRowSelect = true;
            }
            if (base.SmallImageList == null)
            {
                ImageList list = new ImageList();
                list.ImageSize = new Size(0x10, 0x10);
                base.SmallImageList = list;
                this._indendFirstItem = true;
            }
            this._enableVistaCheckBoxes = Utility.IsVista();
            this.InitializeComponent();
            this._designMode = Process.GetCurrentProcess().ProcessName == "devenv";
        }

        private void CleanColumnsTags()
        {
            for (int i = 0; i < base.Columns.Count; i++)
            {
                base.Columns[i].Tag = null;
            }
            base.Invalidate();
        }

        public StringAlignment ConvertHorizontalAlignmentToStringAlignment(HorizontalAlignment input)
        {
            switch (input)
            {
                case HorizontalAlignment.Left:
                    return StringAlignment.Near;

                case HorizontalAlignment.Right:
                    return StringAlignment.Far;

                case HorizontalAlignment.Center:
                    return StringAlignment.Center;
            }
            return StringAlignment.Center;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (this._palette != null)
                {
                    this._palette.PalettePaint -= new EventHandler<PaletteLayoutEventArgs>(this.OnPalettePaint);
                    this._palette = null;
                }
                KryptonManager.GlobalPaletteChanged -= new System.EventHandler(this.OnGlobalPaletteChanged);
            }
            base.Dispose(disposing);
        }

        private void DrawInsertionLine(int X1, int X2, int Y)
        {
            using (Graphics graphics = base.CreateGraphics())
            {
                graphics.DrawLine(Pens.Red, X1, Y, X2 - 1, Y);
                Point[] points = new Point[] { new Point(X1, Y - 4), new Point(X1 + 7, Y), new Point(X1, Y + 4) };
                Point[] pointArray2 = new Point[] { new Point(X2, Y - 4), new Point(X2 - 8, Y), new Point(X2, Y + 4) };
                graphics.FillPolygon(Brushes.Red, points);
                graphics.FillPolygon(Brushes.Red, pointArray2);
            }
        }

        private void InitColors()
        {
            if (!this._persistentColors)
            {
                if (this._useStyledColors)
                {
                    this._gradientStartColor = Color.FromArgb(0xff, 0xf6, 0xd7);
                    this._gradientEndColor = Color.FromArgb(0xff, 0xd5, 0x4d);
                    this._gradientMiddleColor = Color.FromArgb(0xfc, 0xe0, 0x85);
                }
                else
                {
                    this._gradientStartColor = this._palette.ColorTable.StatusStripGradientBegin;
                    this._gradientEndColor = this._palette.ColorTable.OverflowButtonGradientEnd;
                    this._gradientMiddleColor = this._palette.ColorTable.StatusStripGradientEnd;
                }
            }
            this._alternateRowColor = this._palette.ColorTable.ToolStripContentPanelGradientBegin;
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(KryptonListView));
            this.ilCheckBoxes = new ImageList(this.components);
            base.SuspendLayout();
            this.ilCheckBoxes.ImageStream = (ImageListStreamer) manager.GetObject("ilCheckBoxes.ImageStream");
            this.ilCheckBoxes.TransparentColor = Color.Transparent;
            this.ilCheckBoxes.Images.SetKeyName(0, "XpNotChecked.gif");
            this.ilCheckBoxes.Images.SetKeyName(1, "XpChecked.gif");
            this.ilCheckBoxes.Images.SetKeyName(2, "VistaNotChecked.png");
            this.ilCheckBoxes.Images.SetKeyName(3, "VistaChecked.png");
            base.ResumeLayout(false);
        }

        protected override void OnColumnClick(ColumnClickEventArgs e)
        {
            base.OnColumnClick(e);
            if (this._enableSorting)
            {
                if (e.Column == this.lvwColumnSorter.SortColumn)
                {
                    if (this.lvwColumnSorter.Order == SortOrder.Ascending)
                    {
                        this.lvwColumnSorter.Order = SortOrder.Descending;
                    }
                    else
                    {
                        this.lvwColumnSorter.Order = SortOrder.Ascending;
                    }
                }
                else
                {
                    this.lvwColumnSorter.SortColumn = e.Column;
                    this.lvwColumnSorter.Order = SortOrder.Ascending;
                }
                base.Sort();
            }
        }

        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            if (!this.DesignMode)
            {
                if (!this._enableHeaderRendering)
                {
                    e.DrawDefault = true;
                }
                else
                {
                    Color white;
                    Color buttonCheckedGradientEnd;
                    Rectangle bounds = e.Bounds;
                    bounds.Height -= 2;
                    bounds.Width = bounds.Width;
                    Graphics g = e.Graphics;
                    Point pt = new Point();
                    pt = base.PointToClient(Control.MousePosition);
                    bool flag = false;
                    if (this._enableHeaderHotTrack)
                    {
                        base.Invalidate();
                        Rectangle rectangle2 = new Rectangle();
                        rectangle2 = e.Bounds;
                        rectangle2.Width += 2;
                        rectangle2.Height += 2;
                        if (rectangle2.Contains(pt))
                        {
                            flag = true;
                        }
                    }
                    try
                    {
                        e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                    }
                    catch (Exception exception)
                    {
                        Console.Write(exception.Message);
                    }
                    Color toolStripBorder = this._palette.ColorTable.ToolStripBorder;
                    Color statusStripText = this._palette.ColorTable.StatusStripText;
                    if (e.State == ListViewItemStates.Selected)
                    {
                        white = Color.White;
                        buttonCheckedGradientEnd = this._palette.ColorTable.ButtonCheckedGradientEnd;
                        Color buttonCheckedGradientBegin = this._palette.ColorTable.ButtonCheckedGradientBegin;
                        statusStripText = this._palette.ColorTable.MenuItemText;
                    }
                    else if (flag)
                    {
                        white = Color.White;
                        buttonCheckedGradientEnd = this._palette.ColorTable.ButtonSelectedGradientEnd;
                        Color buttonSelectedGradientBegin = this._palette.ColorTable.ButtonSelectedGradientBegin;
                        statusStripText = this._palette.ColorTable.MenuItemText;
                    }
                    else
                    {
                        white = Color.White;
                        buttonCheckedGradientEnd = this._palette.ColorTable.ToolStripGradientEnd;
                        Color toolStripGradientBegin = this._palette.ColorTable.ToolStripGradientBegin;
                        statusStripText = this._palette.ColorTable.StatusStripText;
                    }
                    g.FillRectangle(new SolidBrush(Color.White), bounds);
                    using (LinearGradientBrush brush = new LinearGradientBrush(bounds, white, buttonCheckedGradientEnd, LinearGradientMode.Vertical))
                    {
                        if (!this._enableHeaderGlow)
                        {
                            g.FillRectangle(brush, bounds);
                        }
                        else
                        {
                            DrawingMethods.DrawListViewHeader(g, bounds, white, buttonCheckedGradientEnd, 90f);
                        }
                    }
                    g.DrawRectangle(new Pen(toolStripBorder), bounds);
                    g.DrawLine(new Pen(Color.White), new Point(bounds.X + 1, bounds.Y + 1), new Point((bounds.X + bounds.Width) - 1, bounds.Y + 1));
                    g.DrawLine(new Pen(Color.White), new Point(bounds.X + 1, bounds.Y + 1), new Point(bounds.X + 1, (bounds.Y + bounds.Height) - 1));
                    if (e.ColumnIndex == (base.Columns.Count - 1))
                    {
                        g.DrawLine(new Pen(toolStripBorder), new Point((bounds.X + bounds.Width) - 1, bounds.Y), new Point((bounds.X + bounds.Width) - 1, bounds.Y + bounds.Height));
                    }
                    if (bounds.Height > 15)
                    {
                        if (e.State == ListViewItemStates.Selected)
                        {
                            bounds.Offset(3, 5);
                        }
                        else
                        {
                            bounds.Offset(2, 4);
                        }
                    }
                    else if (e.State == ListViewItemStates.Selected)
                    {
                        bounds.Offset(3, 3);
                    }
                    else
                    {
                        bounds.Offset(2, 2);
                    }
                    StringFormat format = new StringFormat();
                    format.FormatFlags = StringFormatFlags.NoWrap;
                    format.Alignment = this.ConvertHorizontalAlignmentToStringAlignment(e.Header.TextAlign);
                    g.DrawString(e.Header.Text, this.Font, new SolidBrush(statusStripText), bounds, format);
                    if (base.Columns[e.ColumnIndex].Tag != null)
                    {
                        switch (((SortOrder) base.Columns[e.ColumnIndex].Tag))
                        {
                            case SortOrder.Ascending:
                                g.FillRectangle(new SolidBrush(Color.Red), (bounds.X + bounds.Width) - 8, bounds.Y, 8, 8);
                                return;

                            case SortOrder.Descending:
                                g.FillRectangle(new SolidBrush(Color.Green), (bounds.X + bounds.Width) - 8, bounds.Y, 8, 8);
                                return;
                        }
                    }
                }
            }
            else
            {
                e.DrawDefault = true;
            }
        }

        protected override void OnDrawItem(DrawListViewItemEventArgs e)
        {
            if (!this.DesignMode)
            {
                Rectangle bounds = e.Bounds;
                Graphics g = e.Graphics;
                bounds.Height--;
                bounds.Width--;
                try
                {
                    e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                }
                catch (Exception exception)
                {
                    Console.Write(exception.Message);
                }
                if (this._palette == null)
                {
                    EventArgs args = new EventArgs();
                    this.OnGlobalPaletteChanged(this, args);
                }
                if (!this._persistentColors)
                {
                    if (this._useStyledColors)
                    {
                        this._gradientStartColor = Color.FromArgb(0xff, 0xf6, 0xd7);
                        this._gradientEndColor = Color.FromArgb(0xff, 0xd5, 0x4d);
                        this._gradientMiddleColor = Color.FromArgb(0xfc, 0xe0, 0x85);
                    }
                    else
                    {
                        this._gradientStartColor = this._palette.ColorTable.StatusStripGradientBegin;
                        this._gradientEndColor = this._palette.ColorTable.OverflowButtonGradientEnd;
                        this._gradientMiddleColor = this._palette.ColorTable.StatusStripGradientEnd;
                    }
                }
                Color darkColor = this._gradientStartColor;
                Color lightColor = this._gradientEndColor;
                Color statusStripText = this._palette.ColorTable.StatusStripText;
                if (this._forceLeftAlign)
                {
                    foreach (ColumnHeader header in base.Columns)
                    {
                        header.TextAlign = HorizontalAlignment.Left;
                    }
                }
                Console.Write(e.State);
                if (base.View != View.Details)
                {
                    e.DrawDefault = true;
                }
                else if (((e.State & ListViewItemStates.Selected) == 0) || !e.Item.Selected)
                {
                    e.DrawDefault = true;
                }
                else
                {
                    DrawingMethods.DrawGradient(e.Graphics, bounds, darkColor, lightColor, 90f, this._enableSelectionBorder, lightColor, 1f);
                    e.DrawText();
                    if (base.CheckBoxes)
                    {
                        string str;
                        if (e.Item.Checked)
                        {
                            str = "V";
                        }
                        else
                        {
                            str = "O";
                        }
                        e.Graphics.DrawString(str, this.Font, new SolidBrush(statusStripText), bounds);
                        bounds.Offset(0x13, 0);
                    }
                    if (((base.SmallImageList != null) && (e.Item.ImageIndex >= 0)) && (e.Item.ImageIndex < base.SmallImageList.Images.Count))
                    {
                        base.SmallImageList.Draw(g, bounds.X, bounds.Y, 0x10, 0x10, e.Item.ImageIndex);
                    }
                }
            }
            else
            {
                e.DrawDefault = true;
            }
        }

        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            if (!this.DesignMode)
            {
                Rectangle bounds = e.Bounds;
                Graphics g = e.Graphics;
                bounds.Height--;
                bounds.Width--;
                try
                {
                    e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                }
                catch (Exception exception)
                {
                    Console.Write(exception.Message);
                }
                Color statusStripText = this._palette.ColorTable.StatusStripText;
                if (!this._persistentColors)
                {
                    if (this._useStyledColors)
                    {
                        this._gradientStartColor = Color.FromArgb(0xff, 0xf6, 0xd7);
                        this._gradientEndColor = Color.FromArgb(0xff, 0xd5, 0x4d);
                        this._gradientMiddleColor = Color.FromArgb(0xfc, 0xe0, 0x85);
                        statusStripText = this._palette.ColorTable.MenuItemText;
                    }
                    else
                    {
                        this._gradientStartColor = this._palette.ColorTable.StatusStripGradientBegin;
                        this._gradientEndColor = this._palette.ColorTable.OverflowButtonGradientEnd;
                        this._gradientMiddleColor = this._palette.ColorTable.StatusStripGradientEnd;
                        statusStripText = this._palette.ColorTable.StatusStripText;
                    }
                }
                Color darkColor = this._gradientStartColor;
                Color lightColor = this._gradientEndColor;
                if (this._forceLeftAlign)
                {
                    foreach (ColumnHeader header in base.Columns)
                    {
                        header.TextAlign = HorizontalAlignment.Left;
                    }
                }
                if (base.View == View.Details)
                {
                    if ((e.ItemState & ListViewItemStates.Selected) != 0)
                    {
                        DrawingMethods.DrawGradient(e.Graphics, bounds, darkColor, lightColor, 90f, this._enableSelectionBorder, lightColor, 1f);
                        if (base.CheckBoxes && (e.ColumnIndex == 0))
                        {
                            Image image;
                            if (e.Item.Checked)
                            {
                                if (this._enableVistaCheckBoxes)
                                {
                                    image = this.ilCheckBoxes.Images[3];
                                }
                                else
                                {
                                    image = this.ilCheckBoxes.Images[1];
                                }
                            }
                            else if (this._enableVistaCheckBoxes)
                            {
                                image = this.ilCheckBoxes.Images[2];
                            }
                            else
                            {
                                image = this.ilCheckBoxes.Images[0];
                            }
                            if (Utility.IsVista())
                            {
                                bounds.Offset(-2, 0);
                            }
                            g.DrawImage(image, bounds.X + 4, bounds.Y, 0x10, 0x10);
                            bounds.Offset(0x13, 0);
                            if (Utility.IsVista())
                            {
                                bounds.Offset(-1, 0);
                            }
                        }
                        if (e.ColumnIndex == 0)
                        {
                            try
                            {
                                base.SmallImageList.Draw(g, bounds.X + 4, bounds.Y, 0x10, 0x10, e.Item.ImageIndex);
                                if (this._indendFirstItem)
                                {
                                    bounds.Offset(0x10, 0);
                                }
                            }
                            catch (Exception exception2)
                            {
                                Console.Write(exception2.Message);
                                if (this._indendFirstItem)
                                {
                                    bounds.Offset(0x10, 0);
                                }
                            }
                        }
                        bounds.Offset(4, 2);
                        e.Graphics.DrawString(e.SubItem.Text, this.Font, new SolidBrush(statusStripText), bounds);
                    }
                    else
                    {
                        e.DrawDefault = true;
                    }
                }
                else
                {
                    e.DrawDefault = true;
                }
            }
            else
            {
                e.DrawDefault = true;
            }
        }

        private void OnGlobalPaletteChanged(object sender, EventArgs e)
        {
            if (this._palette != null)
            {
                this._palette.PalettePaint -= new EventHandler<PaletteLayoutEventArgs>(this.OnPalettePaint);
            }
            this._palette = KryptonManager.CurrentGlobalPalette;
            this._paletteRedirect.Target = this._palette;
            if (this._palette != null)
            {
                this._palette.PalettePaint += new EventHandler<PaletteLayoutEventArgs>(this.OnPalettePaint);
                this.InitColors();
            }
            base.Invalidate();
        }

        protected override void OnItemMouseHover(ListViewItemMouseHoverEventArgs e)
        {
            base.OnItemMouseHover(e);
        }

        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (this._enableDragDrop)
            {
                this._itemDnD = base.GetItemAt(e.X, e.Y);
            }
            base.OnMouseDown(e);
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (this._enableDragDrop)
            {
                if (this._itemDnD == null)
                {
                    return;
                }
                this.Cursor = Cursors.Hand;
                int y = Math.Min(e.Y, base.Items[base.Items.Count - 1].GetBounds(ItemBoundsPortion.Entire).Bottom - 1);
                ListViewItem itemAt = base.GetItemAt(0, y);
                if (itemAt == null)
                {
                    return;
                }
                Rectangle bounds = itemAt.GetBounds(ItemBoundsPortion.Entire);
                if (e.Y < (bounds.Top + (bounds.Height / 2)))
                {
                    this.LineBefore = itemAt.Index;
                    this.LineAfter = -1;
                }
                else
                {
                    this.LineBefore = -1;
                    this.LineAfter = itemAt.Index;
                }
                base.Invalidate();
            }
            base.OnMouseMove(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (this._enableDragDrop)
            {
                if (this._itemDnD == null)
                {
                    return;
                }
                try
                {
                    bool flag;
                    int y = Math.Min(e.Y, base.Items[base.Items.Count - 1].GetBounds(ItemBoundsPortion.Entire).Bottom - 1);
                    ListViewItem itemAt = base.GetItemAt(0, y);
                    if (itemAt == null)
                    {
                        return;
                    }
                    Rectangle bounds = itemAt.GetBounds(ItemBoundsPortion.Entire);
                    if (e.Y < (bounds.Top + (bounds.Height / 2)))
                    {
                        flag = true;
                    }
                    else
                    {
                        flag = false;
                    }
                    if (this._itemDnD != itemAt)
                    {
                        if (flag)
                        {
                            base.Items.Remove(this._itemDnD);
                            base.Items.Insert(itemAt.Index, this._itemDnD);
                        }
                        else
                        {
                            base.Items.Remove(this._itemDnD);
                            base.Items.Insert(itemAt.Index + 1, this._itemDnD);
                        }
                    }
                    this.LineAfter = this.LineBefore = -1;
                    base.Invalidate();
                }
                finally
                {
                    this._itemDnD = null;
                    this.Cursor = Cursors.Default;
                }
            }
            base.OnMouseUp(e);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
        }

        private void OnPalettePaint(object sender, PaletteLayoutEventArgs e)
        {
            base.Invalidate();
        }

        [PermissionSet(SecurityAction.Demand, Name="FullTrust")]
        protected override void WndProc(ref Message message)
        {
            if (!this.DesignMode && this._autoSizeLastColumn)
            {
                switch (message.Msg)
                {
                    case 15:
                        if ((base.View == View.Details) && (base.Columns.Count > 0))
                        {
                            base.Columns[base.Columns.Count - 1].Width = -2;
                        }
                        for (int i = 0; i < (base.Columns.Count - 1); i++)
                        {
                            base.Columns[i].Width = base.Columns[i].Width;
                        }
                        if (this._enableDragDrop)
                        {
                            if ((this.LineBefore >= 0) && (this.LineBefore < base.Items.Count))
                            {
                                Rectangle bounds = base.Items[this.LineBefore].GetBounds(ItemBoundsPortion.Entire);
                                this.DrawInsertionLine(bounds.Left, bounds.Right, bounds.Top);
                            }
                            if ((this.LineAfter >= 0) && (this.LineBefore < base.Items.Count))
                            {
                                Rectangle rectangle2 = base.Items[this.LineAfter].GetBounds(ItemBoundsPortion.Entire);
                                this.DrawInsertionLine(rectangle2.Left, rectangle2.Right, rectangle2.Bottom);
                            }
                        }
                        break;
                }
            }
            base.WndProc(ref message);
        }

        [Browsable(true), Category("Appearance-Extended"), DefaultValue("Color.Gray")]
        public Color AlternateRowColor
        {
            get
            {
                return this._alternateRowColor;
            }
            set
            {
                this._alternateRowColor = value;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), DefaultValue("true"), Browsable(true)]
        public bool AlternateRowColorEnabled
        {
            get
            {
                return this._alternateRowColorEnabled;
            }
            set
            {
                this._alternateRowColorEnabled = value;
                base.Invalidate();
            }
        }

        [DefaultValue("True"), Browsable(true), Category("Appearance-Extended")]
        public bool AutoSizeLastColumn
        {
            get
            {
                return this._autoSizeLastColumn;
            }
            set
            {
                this._autoSizeLastColumn = value;
                base.Invalidate();
            }
        }

        public bool DesignMode
        {
            get
            {
                return this._designMode;
            }
        }

        [DefaultValue("False"), Browsable(true), Category("Appearance-Extended")]
        public bool EnableDragDrop
        {
            get
            {
                return this._enableDragDrop;
            }
            set
            {
                this._enableDragDrop = value;
            }
        }

        [Browsable(true), DefaultValue("False"), Category("Appearance-Extended")]
        public bool EnableHeaderGlow
        {
            get
            {
                return this._enableHeaderGlow;
            }
            set
            {
                this._enableHeaderGlow = value;
                base.Invalidate();
            }
        }

        [Browsable(true), Category("Appearance-Extended"), DefaultValue("False")]
        public bool EnableHeaderHotTrack
        {
            get
            {
                return this._enableHeaderHotTrack;
            }
            set
            {
                this._enableHeaderHotTrack = value;
                if (value)
                {
                    base.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
                }
                else
                {
                    base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
                }
                base.UpdateStyles();
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Browsable(true), DefaultValue("False")]
        public bool EnableHeaderRendering
        {
            get
            {
                return this._enableHeaderRendering;
            }
            set
            {
                this._enableHeaderRendering = value;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), DefaultValue("True"), Browsable(true)]
        public bool EnableSelectionBorder
        {
            get
            {
                return this._enableSelectionBorder;
            }
            set
            {
                this._enableSelectionBorder = value;
                base.Invalidate();
            }
        }

        [Browsable(true), DefaultValue("True"), Category("Appearance-Extended")]
        public bool EnableSorting
        {
            get
            {
                return this._enableSorting;
            }
            set
            {
                this._enableSorting = value;
            }
        }

        [DefaultValue("True"), Browsable(true), Category("Appearance-Extended")]
        public bool EnableVistaCheckBoxes
        {
            get
            {
                return this._enableVistaCheckBoxes;
            }
            set
            {
                this._enableVistaCheckBoxes = value;
                base.Invalidate();
            }
        }

        [DefaultValue("True"), Browsable(false), Category("Appearance-Extended")]
        public bool ForceLeftAlign
        {
            get
            {
                return this._forceLeftAlign;
            }
            set
            {
                this._forceLeftAlign = value;
            }
        }

        [DefaultValue("Color.Gray"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(true), Category("Appearance-Extended")]
        public Color GradientEndColor
        {
            get
            {
                return this._gradientEndColor;
            }
            set
            {
                this._gradientEndColor = value;
                base.Invalidate();
            }
        }

        [DefaultValue("Color.Gray"), Category("Appearance-Extended"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(true)]
        public Color GradientMiddleColor
        {
            get
            {
                return this._gradientMiddleColor;
            }
            set
            {
                this._gradientMiddleColor = value;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), DefaultValue("Color.White"), Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Color GradientStartColor
        {
            get
            {
                return this._gradientStartColor;
            }
            set
            {
                this._gradientStartColor = value;
                base.Invalidate();
            }
        }

        [DefaultValue("True"), Category("Appearance-Extended"), Browsable(true)]
        public bool IndendFirstItem
        {
            get
            {
                return this._indendFirstItem;
            }
            set
            {
                this._indendFirstItem = value;
            }
        }

        [Category("Appearance-Extended"), Browsable(true)]
        public int LineAfter
        {
            get
            {
                return this._lineAfter;
            }
            set
            {
                this._lineAfter = value;
            }
        }

        [Category("Appearance-Extended"), Browsable(true)]
        public int LineBefore
        {
            get
            {
                return this._lineBefore;
            }
            set
            {
                this._lineBefore = value;
            }
        }

        [DefaultValue("False"), Category("Appearance-Extended"), Browsable(true)]
        public bool PersistentColors
        {
            get
            {
                return this._persistentColors;
            }
            set
            {
                this._persistentColors = value;
                base.Invalidate();
            }
        }

        [Browsable(true), Category("Appearance-Extended"), DefaultValue("True")]
        public bool SelectEntireRowOnSubItem
        {
            get
            {
                return this._selectEntireRowOnSubItem;
            }
            set
            {
                this._selectEntireRowOnSubItem = value;
            }
        }

        [DefaultValue("False"), Browsable(true), Category("Appearance-Extended")]
        public bool UseStyledColors
        {
            get
            {
                return this._useStyledColors;
            }
            set
            {
                this._useStyledColors = value;
                base.Invalidate();
            }
        }
    }
}

